<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h2>组件使用v-model - {{ textValue }}</h2>
      <!-- <child :value="textValue" @input="getvalue"></child> -->
      <child v-model="textValue"></child>
    </div>

    <script src="../Vue.js"></script>
    <script>
      const Child = {
        props: ["value"],
        template: `
          <div>child组件 - <input type="text" :value="value" @input="handleInput" /></div>
        `,
        methods: {
          handleInput(e) {
            // console.log(e.target.value);
            this.$emit("input", e.target.value);
          },
        },
      };

      new Vue({
        el: "#app",
        data: {
          textValue: "abc",
        },
        components: {
          Child,
        },
        // methods: {
        //   getvalue(v) {
        //     this.textValue = v;
        //   },
        // },
      });
    </script>
  </body>
</html>
